home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / pascal / dblk2.zip / DBLOOK.DOC < prev    next >
Text File  |  1989-10-05  |  6KB  |  144 lines

  1. DBLOOK is implimented as a unit for Turbo Pascal 4.0, 5.0, or 5.5.
  2.  
  3. Below is the definition section of the source file to assist in the
  4. calling constructs to use.  If you wish to put the source into your
  5. program file instead of a unit file, it may be easily extracted from the
  6. source code of the DBLOOK unit.
  7.  
  8. unit dblook;
  9. { DBLOOK is a Turbo Pascal Unit which reads Dbase III + .DBF files,
  10.   displays the structure information on the screen, converts from
  11.   Dbase format to various internal formats to assist gathering data
  12.   from Dbase data files.
  13.  
  14.   The program was designed to provide simple routines to read dbase
  15.   files to generate reports.
  16.  
  17.   Only one Dbase file may be open at one time (you may change it as
  18.   the source code is provided) and index files are not supported.
  19.  
  20.   Each record will be placed in a character buffer dbbuf[4096] and
  21.   may be used directly or the functions in this package may be used
  22.   to extract data items of interest into more usable Pascal variables.
  23.  
  24.   If you make major improvements to the program, let me know as
  25.   the ongoing effort to improve the performance of Dbase requires
  26.   more tools. 
  27.   
  28.   Turbo Pascal 5.5 was used to develope the program.
  29.  
  30.   Gerald Rohr   RR#3    Anamosa, Iowa 52205
  31.  
  32.                          Revision History
  33.   ----------------------------------------------------------------
  34.   Rev 1.0 26 Sep 87 Original Release                           gbr
  35.   Rev 2.0 29 Sep 89 Reworked to longints, records, TP5.5       gbr
  36.  }
  37.  
  38. { ----Globals for your program------ }
  39. interface
  40. type
  41.    rdef = record                  { Dbase record definitions we use }
  42.       name       :string[10];
  43.       rtype      :char;           { type of record - C,N,D,L,etc.         }
  44.       fld_addr   :longint;        { not used }
  45.       width      :byte;           { total field width of this record      }
  46.       decp       :byte;           { number of digits to right of decimal  }
  47.       multi_user :integer;        { reserved for multi user }
  48.       work_id    :byte;           { Work area ID }
  49.       m_user     :integer;        { reserved for multi_user }
  50.       set_fields :byte;           { SET_FIELDS flag }
  51.       resrvd     :array[1..8] of byte;      { 8 bytes reserved }
  52.       stloc      :integer;        { offset from start of field where this }
  53.    end;
  54.  
  55.    db4head = record  { Dbase III + header definition        }
  56.       dbvno        :byte;  { version number (03h or 83h ) }
  57.       updyr        :byte;  { last update YY MM DD         }
  58.       updmo        :byte;
  59.       upddy        :byte;
  60.       no_rec       :longint; { number of record in database }
  61.       header_bytes :integer; { number of bytes in header }
  62.       rec_bytes    :integer; { number of bytes in records }
  63.       tmp          :array[1..20] of char;   { reserved bytes in header }
  64.    end;
  65.  
  66. var
  67.    dbbuf    :array[1..4096] of char;{ Dbase record }
  68.    dbhead   :db4head;               { header of DBF file }
  69.    rstru    :array[1..30] of rdef;  { holds our representation of the database structure }
  70.    no_col   :integer;               { number of columns in database }
  71.  
  72.  
  73. procedure showstruc;
  74.           { displays the information found in the dbase header to the
  75.             screen, used primarily to check if the file definition is
  76.             correct. }
  77.  
  78. function get_header(dbfilename:string):boolean;
  79.           { reads and stores header information on a Dbase III+ .dbf
  80.             file. Must be the first call in your program as it opens the
  81.             Dbase file name dbfilename.  Returns true if successfull,
  82.             else returns false.}
  83.  
  84. procedure closedb;
  85.           { Call at end of your application to close the Dbase file.
  86.             For now there is only one file to close, if extended to use
  87.             multiple database files then this procedure would be
  88.             required. }
  89.  
  90. procedure list_all_recs;
  91.          { List all records in the dbase file starting with record 1,
  92.            listing is in a SDF format. }
  93.  
  94. function version_no:string;
  95.          { Returns the string representation of the version of the
  96.            dblook.pas package. }
  97.  
  98. function dbfldno(fname:string):integer;
  99.          { Returns an integer which is the number in the rstru array
  100.            where fname is located.  Used to enable user to use field
  101.            names in functions to return data.  Returns 0 if fname not
  102.            found. }
  103.  
  104. function dbstr(fldno:integer):string;
  105.          { Returns the string representation of any field of the
  106.            database.  This string is filled out to the full field length
  107.            by padding with spaces. }
  108.  
  109. function dbint(fldno:integer):integer;
  110.          { Returns the integer representation of any field of the
  111.            database. }
  112.  
  113.  
  114. function dblong(fldno:integer):longint;
  115.          { Returns the long integer representation of any field of the
  116.            database. }
  117.  
  118.  
  119. function dbreal(fldno:integer):real;
  120.          { Returns the long integer representation of any field of the
  121.            database. }
  122.  
  123.  
  124. function dblogic(fldno:integer):boolean;
  125.          { Returns true or false representing the logical value of the
  126.            field. }
  127.  
  128.  
  129. function deleted:boolean;
  130.          { Returns true if record in dbbuf[] is marked as deleted, else
  131.            returns false. }
  132.  
  133. function get_recno(rec_no:longint):boolean;
  134.           { Fills the dbbuf[] with data from rec_no record of the
  135.             database, returns true if successfull, else returns false
  136.             and dbbuf[] is undefined. }
  137.  
  138. Multiple databases open at the same time may be in the future depending
  139. on the project requirements.
  140.  
  141. Gerry Rohr
  142. RR#3
  143. Anamosa, Iowa 52205
  144.